#include "mytime0.h"
#include "iostream"
Time::Time()
{
    hours = 0;
    minutes = 0;
}
Time::Time(int h, int m)
{
    hours = h;
    minutes = m;
}

void Time::AddHr(int hour) 
{
    hours = hours + hour;
}

void Time::AddMin(int m) {
    minutes = minutes + m;
}

Time Time::operator+(const Time & aTime) const
{
    Time newTime;
    newTime.hours = hours + aTime.hours;
    int sumMinutes = minutes + aTime.minutes;
    newTime.minutes = sumMinutes % 60;
    newTime.hours +=  sumMinutes / 60;
    return newTime;
}
Time Time::operator-(const Time & aTime) const
{
    Time newTime;
    newTime.hours = hours - aTime.hours;
    newTime.minutes = minutes - aTime.minutes;
    if (newTime.minutes < 0)
    {
        newTime.minutes += 60;
        newTime.hours -= 1;
    }
    return newTime;
}

Time Time::operator*(const int n) const 
{
    Time newTime;
    newTime.hours = hours * n;
    newTime.minutes = minutes * n;
    if (newTime.minutes >= 60)
    {
        newTime.hours += newTime.minutes / 60;
        newTime.minutes %= 60;
    }
    return newTime;
}

void Time::Reset(int h, int m)
{
    hours = h;
    minutes = m;
}
void Time::Show() const
{
    using namespace std;
    cout << "Hour:" << hours << " Minutes:" << minutes << endl;
}

Time operator*(const int n, const Time & t)
{
    return t * n;
}

std::ostream & operator<<(std::ostream & os, const Time & t) 
{
    os << "Hours " << t.hours << "Minutes " << t.minutes;
    return os;
}
